package org.ar.gameserver.common.socket;

public class PolicyServerSocket {
	
	public static boolean checkServerSocketPort(int bindPort, String startPortStr, String endPortStr) throws Exception {
		int startPort = Integer.parseInt(startPortStr);
		int endPort = Integer.parseInt(endPortStr);
		if(bindPort >= startPort && bindPort <= endPort) {
			return true;
		} else {
			return false;
		}
	}
	
	public static String createSecurityString(String startPort, String endPort) throws Exception {
		StringBuffer sb = new StringBuffer();
		sb.append(" <?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
		sb.append(" <!DOCTYPE cross-domain-policy SYSTEM \"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd\">\n");
		sb.append(" <cross-domain-policy>\n");
		sb.append(" <site-control permitted-cross-domain-policies=\"all\"/>\n");
		sb.append(" <allow-access-from domain=\"*\" to-ports=\"");
		sb.append(startPort).append("-").append(endPort);
		sb.append("\" />\n");
		sb.append(" </cross-domain-policy>\n");
		
		return sb.toString();
	}
}
